package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/14 11:06
 */
public class LS_Offer_53_1 {
    public int search(int[] nums, int target) {
        int r = 0;
        for (int num : nums) {
            if (num == target) {
                r++;
            }
        }
        return r;
    }

    public int search2(int[] nums, int target) {
        int left = 0, right = nums.length-1;

        while (left < right) {
            int mid = (left+right)/2;
            if (nums[mid] > target) {
                right = mid-1;
            }
            if (nums[mid] <= target) {
                left = mid +1;
            }
        }
        int r = left;
        return 0;

    }
}
